package com.example.shixunandjavagotoyangchen.BoosYang.Day003.Day003_FX2;

import com.example.modelviewpresenter.Model.BasterModel;

import java.util.List;

import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;

/**
 * 作者:二徒
 * 时间：2021/11/4- 8:17
 * 功能实现：
 */
public class CommunityModel  extends BasterModel implements CommunityContion.ofmiss {
    @Override
    public void getofmiss(String name, CommunityCallback communityCallback) {
        CommunityOKhttp.getOkhttp().getRetrofit().create(CommunityApi.class).getcommunity(name)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.computation())
                .subscribe(new Observer<CommunityBean>() {
                    @Override
                    public void onSubscribe(Disposable d) {

                    }

                    @Override
                    public void onNext(CommunityBean communityBean) {

                        List<CommunityBean.DataBean> dataBeans = communityBean.getData();
                        communityCallback.sucommunity(dataBeans);
                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onComplete() {

                    }
                });
    }
}
